package com.cjkj.purchase.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cjkj.common.annotation.Log;
import com.cjkj.common.core.controller.BaseController;
import com.cjkj.common.core.domain.AjaxResult;
import com.cjkj.common.enums.BusinessType;
import com.cjkj.purchase.domain.PurchaseInfoCount;
import com.cjkj.purchase.service.IPurchaseInfoCountService;
import com.cjkj.common.utils.poi.ExcelUtil;
import com.cjkj.common.core.page.TableDataInfo;

/**
 * 采购信息月统计Controller
 * 
 * @author cjkj
 * @date 2025-02-20
 */
@RestController
@RequestMapping("/purchase/count")
public class PurchaseInfoCountController extends BaseController
{
    @Resource
    private IPurchaseInfoCountService purchaseInfoCountService;

    /**
     * 查询采购信息月统计列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PurchaseInfoCount purchaseInfoCount)
    {
        startPage();
        List<PurchaseInfoCount> list = purchaseInfoCountService.selectPurchaseInfoCountList(purchaseInfoCount);
        return getDataTable(list);
    }

    /**
     * 导出采购信息月统计列表
     */
    @Log(title = "采购信息月统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PurchaseInfoCount purchaseInfoCount)
    {
        List<PurchaseInfoCount> list = purchaseInfoCountService.selectPurchaseInfoCountList(purchaseInfoCount);
        ExcelUtil<PurchaseInfoCount> util = new ExcelUtil<PurchaseInfoCount>(PurchaseInfoCount.class);
        util.exportExcel(response, list, "采购信息月统计数据");
    }

    /**
     * 获取采购信息月统计详细信息
     */
    @GetMapping(value = "/{countId}")
    public AjaxResult getInfo(@PathVariable("countId") Long countId)
    {
        return success(purchaseInfoCountService.selectPurchaseInfoCountByCountId(countId));
    }

    /**
     * 新增采购信息月统计
     */
    @Log(title = "采购信息月统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PurchaseInfoCount purchaseInfoCount)
    {
        return toAjax(purchaseInfoCountService.insertPurchaseInfoCount(purchaseInfoCount));
    }

    /**
     * 修改采购信息月统计
     */
    @Log(title = "采购信息月统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PurchaseInfoCount purchaseInfoCount)
    {
        return toAjax(purchaseInfoCountService.updatePurchaseInfoCount(purchaseInfoCount));
    }

    /**
     * 删除采购信息月统计
     */
    @Log(title = "采购信息月统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{countIds}")
    public AjaxResult remove(@PathVariable Long[] countIds)
    {
        return toAjax(purchaseInfoCountService.deletePurchaseInfoCountByCountIds(countIds));
    }
}
